home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Select (Limited Edition)
/
Computer Select.iso
/
pcmag
/
v10n20
/
delay.asm
< prev
next >
Wrap
Assembly Source File
|
1991-10-28
|
5KB
|
102 lines
;**********************************************************************
; DELAY.ASM .BIN file to delay n timer ticks
; Author..: Sal Ricciardi
;
; Use this file for program delays that are the same irregardless
; of CPU type and speed. Relies on the BIOS timer tick count.
; Maximum delay is 65535 ticks (about 1 hr). Does not validate
; passed parameters.
;
; Create with: TASM delay (Borland Turbo Assembler 2.5)
; TLINK delay
; EXE2BIN delay
; DEL DELAY.OBJ
; DEL DELAY.MAP
; DEL DELAY.EXE
;
; Usage: (dBASE III Plus, FoxBASE+, dBASE IV)
;
; .LOAD DELAY
; .ticks = 10 * 18.2 && for 10 seconds
; .CALL DELAY WITH STR(ticks) && Don't forget the parameter
; .RELEASE DELAY
;
;**********************************************************************
.MODEL SMALL
.CODE
Timerlow EQU WORD PTR ds:[06ch]
delay PROC FAR ;entry point
push ax ;save registers
push cx ;
push ds ;
push es ;
push si ;
;
call asc2bin ;convert parameter to binary
mov cx,ax ;get ticks in cx
jcxz d999 ;if cx==0, skip it
mov ax,040h ;
mov ds,ax ;ds == 040h
d010: ;
mov ax,Timerlow ;get timer tick count low
d020: ;
cmp ax,Timerlow ;watch for it to change
je d020 ;keep watching until it does
loop d010 ;keep looping until cx == 0
d999: ;
pop si ;restore registers
pop es ;
pop ds ;
pop cx ;
pop ax ;
ret ;return to caller
delay ENDP
;----------------------------------------------------------------------
; asc2bin Convert ascii decimal string to 16-bit unsigned binary
;
; Entry: DS:BX --> ascii string
; Exit: AX = 16-bit number
;
; Ignores leading blanks, then conversion stops at null or first
; non numeric.
;----------------------------------------------------------------------
asc2bin PROC
push bx ;Save bx and dx
push dx ;
mov si,bx ;Get offset in si
xor ax,ax ;Clear ax
xor bx,bx ;and bx
xor dx,dx ;and dx
a00001: ;
cmp BYTE PTR ds:[si],' ' ;q. leading blanks?
jne a00010 ;a. no.. move on
inc si ;a. yes.. ignore leading blanks
jmp a00001 ;(so we can use STR() function)
;
a00010: lodsb ;Get next ascii byte
or al,al ;q. is it zero?
jz a00090 ;a. yes .. finished
cmp al,'9' ;q. is > 9?
ja a00090 ;a. yes .. finished
cmp al,'0' ;q. is it < 0?
jb a00090 ;a. yes .. finished
a00020: ;Multiply current answer by 10
mov dx,bx ;Save in dx
shl bx,1 ;* 2
shl bx,1 ;* 4
add bx,dx ;* 5
shl bx,1 ;* 10
and ax,0fh ;Mask off ascii
add bx,ax ;Add to result
jmp a00010 ;go get next byte
a00090: ;
mov ax,bx ;Put result in ax
pop dx ;Restore registers
pop bx ;
ret ;return to caller
asc2bin ENDP
END delay